package com.ms.p2p.provider.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ms.common.utils.SpringContextHolder;
import com.ms.p2p.entity.system.Setting;
import com.ms.p2p.provider.SettingProvider;
import com.ms.p2p.service.impl.SettingServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;

import java.util.List;

/**
 * Created by daimajia on 2015/4/19 添加dubbo接口.
 */
@Service
public class SettingProviderImpl implements SettingProvider {
    @Autowired
    SettingServiceImpl settingService;
    private static CacheManager cacheManager = SpringContextHolder.getBean(CacheManager.class);

    public String findValueByCode(String nid) {
        return settingService.findValueByCode(nid);
    }

    public List<Setting> findByType(int type) {
        return settingService.findByType(type);
    }

    public List<Setting> findAll() {
        return settingService.findAll();
    }

    public Setting findByCode(String nid) {
        return settingService.findByCode(nid);
    }

    public int insert(Setting map) {
        return settingService.insert(map);
    }

    public int update(Setting map) {
        return settingService.update(map);
    }

    public int delete(String id) {
        return settingService.delete(id);
    }


    public void clearCache() {
        for (String cacheName : cacheManager.getCacheNames()) {
            cacheManager.getCache(cacheName).clear();

        }

    }

}